package com.ruoyi.car.controller.carmanage;

import com.alibaba.fastjson.JSON;
import com.car.pojo.GPS;
import com.car.pojo.GpsZuoBiao;
import com.ruoyi.car.service.carmanage.GpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 车辆监控Controller
 *
 * @author 韩昊昌
 * @date 2020-07-01
 */
@RestController
@RequestMapping("/gps")
public class GpsController {


    @Autowired
    private GpsService gpsService;


    /**
     * 接收车辆数据
     * @param gps
     * @return
     */
        @RequestMapping(value = "/send" , method = RequestMethod.POST)
        public Map<String, String> sendGps(@RequestBody GPS gps){
            System.out.println(gps);
            gpsService.addGps(gps);
            HashMap<String, String> map = new HashMap<>();
            map.put("msg","success");
            return map;
    }

    /**
     * 接收车辆坐标
     */
    @RequestMapping(value = "/sendZuoBiao" , method = RequestMethod.POST)
    public void   Zuobiao(@RequestBody GPS gps){

        GPS gps1 = new GPS();
        String latitude = gps.getLatitude();
        String longitude = gps.getLongitude();
        gps1.setLatitude(latitude);
        gps1.setLongitude(longitude);
        gpsService.addGps(gps1);
        System.out.println("+++++++++++++++++"+gps1);
    }

}
